Component({
  options: {
    multipleSlots: true
  },
  properties: {
    msg: { //提示内容
      type: String,
      value: ''
    },
    align: { //文本对齐方式，left,center,right
      type: String,
      value: 'center'
    },
    type: { //提示类型 info/success/error
      type: String,
      value: 'info'
    },
    delay: { //提示内容显示后隐藏的ms值
      type: [Number,String],
      value: 2000
    },
    show:{ //是否显示Toptips
      type: Boolean,
      value: false,
      observer: function (newVal, oldVal) {
        if(newVal){
          this.bindShowToptip();
        }
      }
    }
  },
  data: {
  },
  methods: {
    bindShowToptip(){
      let tip = wx.createAnimation({
        duration: 500, 
        timingFunction: 'ease'
      });
      tip.opacity(1).translateY(0).top('10px').step();
      this.setData({
        tipAnimation: tip.export()
      })
      setTimeout(()=>{
        this.hideToptip();
      },this.data.delay)
    },
    //隐藏课程问答
    hideToptip(){
      let tip = wx.createAnimation({
        duration: 500, 
        timingFunction: 'ease' 
      });
      tip.opacity(0).translateY('-100%').step();
      this.setData({
        tipAnimation: tip.export(),
        show:false
      })
      this.triggerEvent('hide')
    }
  }
})
